package com.cf.api.config;

import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.ByteArrayHttpMessageConverter;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

import java.util.List;

@Configuration
public class GlobalMvcConfig extends WebMvcConfigurationSupport {

    @Autowired
    private FastJsonHttpMessageConverter fastJsonConverter;

    @Override
    protected void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
        super.configureMessageConverters(converters);
        converters.add(new ByteArrayHttpMessageConverter()); // ByteArrayHttpMessageConverter 必须加在前面，处理byte数据
        converters.add(fastJsonConverter);// fastjsonConverter 必须加在后面 处理json数据
    }

}
